package com.lyk.read.book.view

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import com.lyk.read.book.R

/**
 * Created by LianYongKe on 2024/3/13.
 */
class PlaceView @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {

    private val mLoadingView: FrameLayout by lazy { findViewById(R.id.place_loading_layout) }
    private val mEmptyView: FrameLayout by lazy { findViewById(R.id.place_empty_layout) }

    init {
        LayoutInflater.from(context).inflate(R.layout.view_place, this)
    }


    fun setPlaceType(type: Int, content: View?) {
        when (type) {
            1 -> {
                mLoadingView.visibility = View.VISIBLE
                mEmptyView.visibility = View.GONE
                content?.visibility = View.GONE
            }

            2 -> {
                mLoadingView.visibility = View.GONE
                mEmptyView.visibility = View.VISIBLE
                content?.visibility = View.GONE
            }
        }
    }

}